package com.mindskip.xzs.domain.enums;

import java.util.stream.Stream;

public enum ExamStatusEnum {

    ING(0, "正在考试"),
    WAIT(1, "等待考试"),
    DONE(2, "已结束");

    int code;
    String name;

    ExamStatusEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static ExamStatusEnum of(int code) {
        return Stream.of(ExamStatusEnum.values())
                .filter(it -> it.getCode() == code)
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("未找到该枚举类型：" + code));
    }
}
